package lion.test.install;

import lion.framework.core.install.SystemInstaller;
import lion.framework.core.web.anno.Path;
import lion.framework.core.web.anno.Result;
import lion.framework.core.web.anno.View;
import lion.framework.core.web.request.Request;
import lion.framework.core.web.views.ResultType;

public class InstallAction {

	// @Path("/install")
	@Result({ @View("/install/install.jsp"), @View(name = "license", value = "/install/license", type = ResultType.REDIRECT) })
	public String install(Request request) throws Exception {

		if (!request.getSession().getBoolean("agree")) { return "license"; }

		SystemInstaller.install(request);

		return "success";
	}

	@Path("/install/license")
	@Result({ @View("/install/license.jsp"), @View(name = "setup", value = "/install/setup", type = ResultType.REDIRECT) })
	public String license(Request request) {

		if (request.getBoolean("agree")) {
			request.getSession().put("agree", "true");

			return "setup";
		}
		return "success";
	}

	@Path("/install/setup")
	@Result({ @View("/install/setup.jsp"), @View(name = "license", value = "/install/license", type = ResultType.REDIRECT) })
	public String setup(Request request) {

		if (!request.getSession().getBoolean("agree")) { return "license"; }

		return "success";
	}
}
